<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!--#include file="DataLoad.asp"-->
<%Call CheckAdmin2()%>

<html>
<head>
<title><%=GuildName%> - DKP系统</title>
<script language="JavaScript" src="inc/jquery.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="Generator" content="EditPlus">
<meta name="Author" content="SULei">
<meta name="Keywords" content="DKP WOW GUILD">
<meta name="Description" content="">
<link href="<%=StylePath%>/main.css" rel="stylesheet" type="text/css" />
<script language="JavaScript" src="<%=StylePath%>/styleplus.js"></script>
<style type="text/css" media="all">
</style>
</head>

<body>
<div class="header">
<!--#include file="menu.asp"-->
</div>
<div class="main">
			<%
			if Request.form("ArrPlayer")<>"" then
				
			end if
			if Request("id")<>"" then
				call player_edit(Request("id"))
			else
				select case Request("action")
				case "add"
				call player_addsql()
				case "edit"
				call player_editsql()
				case "del"
				call raidplan_delsql()
				case "addplayer"
				call player_add()
				case else
					Select Case Request("order")
					Case "name"
						call player_list("where 1=1","player_name")
					Case "class"
						call player_list("where 1=1","player_profession")
					Case "DKP"
						call player_list("where 1=1","player_BaseDKP")
					Case "raidnum"
						call player_list("where 1=1","player_raidnum")
					Case "tribe"
						call player_list("where 1=1","player_tribe")
					Case "join"
						call player_list("where 1=1","player_jointime")
					Case "status"
						call player_list("where 1=1","player_name")
					Case else
						call player_list("where 1=1","player_name")
					end select
				end select
			end if
			%>
</div>
<div id="footer"><!--#include file="footer.asp"--></div>

</body>
</html>
<%
sub player_list(s,o)
	sql="select * from player "&s&" order by "&o
	rs.open sql,conn,1,1
		if rs.bof or rs.eof then
			Response.write "<a href='?action=addplayer'>添加成员</a>"
		else	
			Response.write "<form method='post' action=''><table class='playerlist outframe interlace hasfocus'>"
			Response.write "<tr><th colspan='6'><div class='title'><img src='images/icon/human_f.gif' >成员列表 [<a href='?action=addplayer'>添加成员</a>]</div><div class='filter'>总计"&rs.recordcount&"名成员</div></th></tr>"
			Response.write "<tr class='coltitle'><td><a href='?order=name'>姓名</a></td><td>职务</td><td><a href='?order=tribe'>种族</a> <a href='?order=class'>职业</a></td><td><a href='?order=raidnum'>出场</a></td><td><a href='?order=join'>入会时间</a></td><td>操作</td></tr>"
			for i = 1 to rs.recordcount
				Response.write "<tr><td><!-- <input type='checkbox' name='ArrPlayer' value='"&rs("id")&"' /> -->"&rs("player_name")&"</td><td>"&rs("player_guildlevel")&"</td><td>"&rs("player_tribe")&rs("player_profession")&"</td>"
				Response.write "<td>"&dkpview(rs("player_raidnum"))&"</td><td>"&rs("player_jointime")&"</td><td><a class='abtn' href=admin_player.asp?id="&rs("id")&">编辑</a> <a name='del' class='abtn4' href='?Action=del&delid="&rs("id")&"'>删除</a></td></tr>"
				rs.movenext
				if rs.eof then exit for
			next
			Response.write ""
			Response.write ""
			Response.write "<tr><th colspan='6'><!-- [全选] [反选] [取消] 选中成员操作: [修改个人信息] [<a href='123.asp' onclick='javasrcipt:submit();'>增加特殊事件</a>] [] --></th></tr>"
			Response.write "</table></form>"
		end if
	rs.close
end sub

SUB player_add()
	Response.write "<form action='?action=add' method='post'>"
	Response.write "<table class='outframe interlace'>"
	Response.write "<tr><th colspan='2'>添加新会员</th></tr>"
	Response.write "<tr><td>姓名</td><td><input type='input' name='player_name' value=''/>检查是否已存在</td></tr>"
	Response.write "<tr><td>种族职业</td><td>"&tribeselect("player_tribe","")&" "&proselect("player_profession","")&"</td></tr>"
	Response.write "<tr><td>等级</td><td><input type='input' name='player_level' value='"&DefalutPlayerLevel&"'/></td></tr>"
	Response.write "<tr><td>加入时间</td><td><input type='input' name='player_jointime'/> 留空则取当前日期</td></tr>"
	Response.write "<tr><td>职务</td><td><input type='input' name='player_guildlevel' value=''/></td></tr>"
	Response.write "<tr><td>技能A</td><td>"&skillselect("player_skill_1","")&"</td></tr>"
	Response.write "<tr><td>技能B</td><td>"&skillselect("player_skill_2","")&"</td></tr>"
	Response.write "<tr><td>备注</td><td><textarea name='player_note' rows='8' cols='50'></textarea></td></tr>"
	Response.write "<tr><td></td><td><input type='submit' value='确定'/></td></tr>"
	Response.write "</table>"
	Response.write "</form>"
End SUB

sub player_addsql()
	'验证提交数据有效性
	Dim errorinfo
	if request("player_name")="" then errorinfo=errorinfo & "<li>姓名不能留空.</li>"
	if not IsDate(request("player_jointime")) and request("player_jointime")<>"" then errorinfo=errorinfo & "<li>加入时间的格式不正确,请按yyyy-mm-dd的格式书写.</li>"
	if not IsNumeric(request("player_level")) and request("player_level")<>"" then errorinfo=errorinfo & "<li>等级必须为数字.</li>"
	if request("player_skill_1")=request("player_skill_2") and request("player_skill_2")<>"未知" then errorinfo=errorinfo & "<li>玩家的商业技能重复.</li>"
	'验证///

	if errorinfo<>"" then
		'抛出错误提示
		Response.write "<p>表单信息有误,提示如下:</p><ul>"&errorinfo&"</ul>"
		Response.write "请<a href='"&Url&"'>返回</a>重新修改."
	else
		'写入数据库
		Sql="Select * from player where (id is null)"
		rs.open sql,conn,1,3
		rs.addnew
		rs("player_name")=trim(request("player_name"))
		rs("player_profession")=trim(request("player_profession"))
		rs("player_tribe")=trim(request("player_tribe"))
		rs("player_level")=trim(request("player_level"))
		rs("player_honor")=""
		if request("player_jointime")="" then 
			rs("player_jointime")=date()
		else
			rs("player_jointime")=trim(request("player_jointime"))
		end if
		rs("player_guildlevel")=trim(request("player_guildlevel"))
		rs("player_DKP")=0
		rs("player_skill_1")=trim(request("player_skill_1"))
		rs("player_skill_2")=trim(request("player_skill_2"))
		rs("player_note")=request("player_note")

		rs("player_activist")=0
		rs("player_looted")=request("player_looted")
		rs("player_raidnum")=0
		rs("player_state")="正常"
		rs.update
		rs.close
		call showmessage("添加完成! <a href='"&Url&"'>继续添加</a>  <a href='admin_player.asp'>查看列表</a>")
	end if
end sub

SUB player_edit(id)
	if Session(ULVL)>1 then 
		showerror("权限不足")
		exit sub
	end if
	if not IsNumeric(Request("id")) then exit sub
	sql="select * from player where id="&Request("id")
	rs.open sql,conn,1,1
	if rs.eof or rs.bof then
	Response.write "错误"
	exit sub
	end if	
	Response.write "<form action='?action=edit' method='post'>"
	Response.write "<table class='outframe interlace'>"
	Response.write "<tr><th colspan='2'>会员资料编辑</th></tr>"
	Response.write "<tr><td>姓名</td><td><input type='input' name='player_name' value='"&rs("player_name")&"'/></td></tr>"
	Response.write "<tr><td>职业</td><td>"&proselect("player_profession",rs("player_profession"))&"</td></tr>"
	Response.write "<tr><td>种族</td><td>"&tribeselect("player_tribe",rs("player_tribe"))&"</td></tr>"
	Response.write "<tr><td>等级</td><td><input type='input' name='player_level' value='"&rs("player_level")&"'/></td></tr>"
	Response.write "<tr><td>加入时间</td><td><input type='input' name='player_jointime' value='"&rs("player_jointime")&"'/> 留空则取当前日期</td></tr>"
	Response.write "<tr><td>组织职务</td><td><input type='input' name='player_guildlevel' value='"&rs("player_guildlevel")&"'/></td></tr>"
	Response.write "<tr><td>商业技能</td><td>"&skillselect("player_skill_1",rs("player_skill_1"))&skillselect("player_skill_2",rs("player_skill_2"))&"</td></tr>"
	Response.write "<tr><td></td><td></td></tr>"
	Response.write "<tr><td>获取装备</td><td><textarea name='player_looted' rows='3' cols='50'>"&rs("player_looted")&"</textarea>只读</td></tr>"
	Response.write "<tr><td>参加次数</td><td><input type='input' name='player_raidnum' value='"&rs("player_raidnum")&"'/></td></tr>"
	Response.write "<tr><td>活跃度</td><td><input type='input' name='player_activist' value='"&rs("player_activist")&"'/></td></tr>"
	Response.write "<tr><td>状态</td><td>"&playerstatusselect("player_state",rs("player_state"))&"</td></tr>"
	Response.write "<tr><td>备注</td><td><textarea name='player_note' rows='5' cols='50'>"&rs("player_note")&"</textarea></td></tr>"
	Response.write "<tr><td></td><td><input type='submit' value='确定'/> <input type='hidden' name='postid' value='"&Request("id")&"' /></td></tr>"
	Response.write "</table>"
	Response.write "</form>"
	rs.close
End SUB

sub player_editsql()
	'验证提交数据有效性
	Dim errorinfo
	if request("player_name")="" then errorinfo=errorinfo & "<li>姓名不能留空.</li>"
	if not IsDate(request("player_jointime")) and request("player_jointime")<>"" then errorinfo=errorinfo & "<li>加入时间的格式不正确,请按yyyy-mm-dd的格式书写.</li>"
	if not IsNumeric(request("player_level")) and request("player_level")<>"" then errorinfo=errorinfo & "<li>等级必须为数字.</li>"
	if request("player_skill_1")=request("player_skill_2") and request("player_skill_2")<>"未知" then errorinfo=errorinfo & "<li>玩家的商业技能重复.</li>"
	'验证///

	if errorinfo<>"" then
		'抛出错误提示
		Response.write "<p>表单信息有误,提示如下:</p><ul>"&errorinfo&"</ul>"
		Response.write "请<a href='"&Url&"'>返回</a>重新修改."
	else
		'写入数据库
		Sql="Select * from player where id="&request("postid")
		rs.open sql,conn,1,3
		rs("player_name")=trim(request("player_name"))
		rs("player_profession")=trim(request("player_profession"))
		rs("player_tribe")=trim(request("player_tribe"))
		rs("player_level")=trim(request("player_level"))
		rs("player_honor")=""
		if request("player_jointime")="" then 
			rs("player_jointime")=date()
			rs("player_state")="正常"
		else
			rs("player_jointime")=trim(request("player_jointime"))
			rs("player_state")=request("player_state")
		end if
		rs("player_guildlevel")=trim(request("player_guildlevel"))
		rs("player_BaseDKP")=request("player_BaseDKP")
		rs("player_DKP")=request("player_DKP")
		rs("player_skill_1")=trim(request("player_skill_1"))
		rs("player_skill_2")=trim(request("player_skill_2"))
		rs("player_note")=request("player_note")

		rs("player_activist")=request("player_activist")
		'rs("player_looted")=request("player_looted")
		rs("player_raidnum")=request("player_raidnum")
		rs.update
		rs.close
		Response.Redirect "admin_player.asp"
	end if
end sub

SUb raidplan_delsql()
	if Session(ULVL)>1 then
	showerror("权限不足")
	exit sub
	else
	sql="Delete * from player where id="&Request("delid")
	conn.execute (sql)
	Response.Redirect "admin_player.asp"
	end if
End Sub
%>